package com.yh.ssm.controller;

import java.io.IOException;

import org.apache.struts2.ServletActionContext;

public class LoginAction {

	private String login; 
	
	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String name() throws IOException{
		
		String name=ServletActionContext.getRequest().getParameter("name");
	
		String name1=null;
		if(name.length()<1){
			login="用户名不能为空!";
		}
	
		return "success";
		
		
	}
public String psd() throws IOException{
		
		String psd=ServletActionContext.getRequest().getParameter("psd");

	
		if(psd.length()<1){
			login="密码不能为空!";
		}
		
		return "success";
		
		
	}
public String lo() throws IOException{
	String name=ServletActionContext.getRequest().getParameter("name");
	String psd=ServletActionContext.getRequest().getParameter("psd");
	if((psd.equals("admin")&&name.equals("admin"))||(psd.equals("123")&&name.equals("123"))){
		ServletActionContext.getRequest().getSession().setAttribute("name", name);
		return "success";
	}else{
		return "error";
	}
}
}
